;
/**
 * 应用页面显示
 */
function BiTheme() {
	var theme = this;
	var $themeContainer = $(".theme-container");
	var $rightdesignView = $themeContainer.find("#tempo-theme-index-view-right-container");
	var $rightappView = $themeContainer.find("#tempo-app-index-view-right-container");
	var $editBtn = $themeContainer.find('.edit-btn');
	var $refreshBtn = $themeContainer.find('.refresh-btn');
	var $themeBoard = $themeContainer.find(".theme-board");
	var $themeToolbar = $themeContainer.find(".tempo-strap-header");
	var $searchBar = $themeContainer.find("#tempo-theme-search-bar");
	var $themeTree = $themeContainer.find('#tempo-theme-tree');
	var $themeTabs = $themeContainer.find(".tempo-strap-panel-tabs");
	var $pubSearchBar = $themeContainer.find("#tempo-theme-public-search-bar"); 
	var $pubThemeTree = $themeContainer.find('#tempo-theme-public-tree');
	var isCGGLY = $themeContainer.attr("_isCGGLY") == "1";
	var isSJRY = $themeContainer.attr("_isSJRY") == "1";
	var currentUserId = $themeContainer.attr("_currentUserId");
	var $tableName = $('#tempo-header-themName');
	var $leftTilte = $('.tempo-strap-panel-title');
	var fType=$themeContainer.attr("ftype");
	var workSpaceId=$themeContainer.attr("workspaceid");
	var $treeSortPanel = $('.tempo-tree-sort');	
	var curFolderId = null;
	var alertDialogWidth = 500;
	var alertDialogHeight = 197;
	var themeTreeSort='DEFAULT';
	var analyse = $themeContainer.data("resource");
	var linkPublishId=null;
	
	var layout = function() {
		$themeContainer.layout({
			west: {
				size: 227,
				resizable : false,
				spacing_open : 0,
				closable : false
			},
			center: {
				
			}
		});
		$themeBoard.layout({
			north: {
				size: 90,
				resizable : false,
				spacing_open : 0,
				closable : false
			}
		});
	}
	
	var beforeMenuShow = function(data, level) {
		var workspacetype = $('.theme-container').attr('workspacetype');
		if(data && data.fileType == 'FOLDER') {
			if(data.id == "share"){
				return;
			}
			var menu = ['createFolder','createTheme','importTheme', "renameFolder", 'deleteFolder'];
			if (data.id == "-1"){
				// 根节点不能重命名
				menu.splice(3);
				return menu;
			}
			if ((workspacetype=='self'&&level > 1)||(workspacetype=='public'&&level > 0)) {
				menu.splice(0, 1);
				return menu;
			}
			return menu;
		}else if(data && data.fileType == 'FILE'){
			if(workspacetype=='self'){
				if (data.belong == "1"){
					// 我的应用
					return ['edit','copyTo','export','move','delete','rename'];
				} else {
					// 邀请我的
					return ['edit','copyTo','export',"removePrivilege"];
				}
			}
			return ['edit','copyTo','export','move','delete','rename'];
			
		}else if(data && data.fileType == 'VIRTUAL_FOLDER'){
			
		}
	}
	
	var getMenus = function(){
		var menus = [{
				text: TempoUtils.locale("bidesign.new_folder"),
				id:'createFolder'
			},{
				text: TempoUtils.locale("bidesign.new_theme"),
				id:'createTheme'
			},{
				text: TempoUtils.locale("bidesign.import_theme"),
				id:'importTheme'
			},{
				text: TempoUtils.locale("bidesign.rename_folder"),
				id:'renameFolder'
			},{
				text: TempoUtils.locale("bidesign.delete_folder"),
				id:'deleteFolder'
			},{
				text: TempoUtils.locale("bi.base_edit"),
				id:'edit'
			},{
				text: TempoUtils.locale("bi.base_rename"),
				id:'rename'
			},{
				text: TempoUtils.locale("bi.base_copy"),
				id:'copy'
			},{
				text: TempoUtils.locale("bi.base_copy"),
				id:'copyTo'
			},{
				text: TempoUtils.locale("bi.scene_viewdata_export"),
				id:'export'
			},{
				text: TempoUtils.locale("bidesign.move"),
				id:'move'
			},{
				text: TempoUtils.locale("bi.base_remove"),
				id:'delete'
			},{
				text: TempoUtils.locale("bidesign.remove"),
				id:'removePrivilege'
			}
		];
		return menus;
	}
	
	var expandFirst = function(){
		if ($searchBar.searchbar("getValue").trim() == ""){
			$themeTree.gtree("expand", "share");
			$themeTree.gtree("expand", "-1");
		}
	}
	
	var initPubTree = function(rootData) {
		if ($pubThemeTree.hasClass("tempo-gtree")){
			$pubThemeTree.gtree("destroy");
		}
		$pubThemeTree.gtree({
			url:contextPath + '/api/bi/resource/tree/list-public-analyse',
			enableSelect:true,
			rootData: rootData,
			beforeRequest:function(data){
				var param = {
					parentId: data.id || "",
					searchWord: data.searchWord || "",
					workSpaceId:$(".theme-container").attr('workspaceid'),
					sort:themeTreeSort,
					searchThemeId:data.searchThemeId     
				};
				return param;
			},
			getItemIcon:function(nodeData){
			    if(nodeData.device=="desktop"){
			    	return 'tempo-api-icon-tree-16 tempo-api-icon-tree-16-position-8'
			    }
			    return 'tempo-api-icon-tree-16 tempo-api-icon-tree-16-position-20'
			    
			},
			getFolderCloseIcon:function(nodeData){
				if (nodeData.fileType == "FOLDER") {
					return "tempo-ui-icon-api-folder-close";
				}
				if (nodeData.type == "visual") {
					return "tempo-api-icon-tree-16 tempo-api-icon-tree-16-position-10";
				}
				return "tempo-ui-icon-api-folder-close";
			},
			
			getFolderOpenIcon:function(nodeData){
				if (nodeData.fileType == "FOLDER") {
					return "tempo-ui-icon-api-folder-open";
				}
				if (nodeData.type == "visual") {
					return "tempo-api-icon-tree-16 tempo-api-icon-16-tree-position-9";
				}
				return "tempo-ui-icon-api-folder-open";
			},
			onSelect:function(nodeData){
				var item = $(this);
				var that=$("#tempo-theme-public-tree");
				if(that.find(".tempo-icon-select").length>0 ){
					that.find(".tempo-icon-select").removeClass("tempo-api-icon-tree-16-position-8-selected");
					that.find(".tempo-icon-select").removeClass("tempo-api-icon-tree-16-position-20-selected");
					that.find(".tempo-icon-select").removeClass("tempo-api-icon-tree-16-position-9-selected");
					that.find(".tempo-icon-select").removeClass("tempo-api-icon-tree-16-position-10-selected")
					that.find(".tempo-icon-select").removeClass("tempo-ui-icon-api-folder-open-selected")
					that.find(".tempo-icon-select").removeClass("tempo-ui-icon-api-folder-close-selected");
					that.find(".tempo-icon-select").removeClass("tempo-icon-select");
			    };
				if(nodeData.type == "scene"||nodeData.type=="report"||nodeData.type=="word"){
					if(nodeData.device=="desktop"){
						item.find("span:eq(0)").addClass("tempo-api-icon-tree-16-position-8-selected")	;
						item.find("span:eq(0)").addClass("tempo-icon-select");
					}else{
						item.find("span:eq(0)").addClass("tempo-api-icon-tree-16-position-20-selected")	;
						item.find("span:eq(0)").addClass("tempo-icon-select");
					}
				};
				if(nodeData.type == "visual"&&nodeData.fileType != 'FOLDER'){
					if(item.find("span:eq(0)").hasClass("tempo-api-icon-16-tree-position-9")){
						item.find("span:eq(0)").addClass("tempo-api-icon-tree-16-position-10-selected");
						item.find("span:eq(0)").addClass("tempo-icon-select");
					}else{
						item.find("span:eq(0)").addClass("tempo-api-icon-tree-16-position-9-selected");
						item.find("span:eq(0)").addClass("tempo-icon-select");
					}
					
				};
				if(nodeData.type == "visual"&&nodeData.fileType == 'FOLDER'){
					if(item.find("span:eq(0)").hasClass("tempo-ui-icon-api-folder-close")){
						item.find("span:eq(0)").addClass("tempo-icon-select");
						item.find("span:eq(0)").addClass("tempo-ui-icon-api-folder-open-selected");
					}else{
						item.find("span:eq(0)").addClass("tempo-icon-select");
						item.find("span:eq(0)").addClass("tempo-ui-icon-api-folder-close-selected");
					}
				}
			},
			isLeafNode:function(nodeData){
				return nodeData.type == 'scene' || nodeData.type == "report" || nodeData.type == "word" ;
			},
			
			onItemClick:  function(data) {
				$rightappView.show();
				$rightdesignView.hide();
				$rightappView.empty();
				$m.loadPage(contextPath + '/api/bi/app/view/achievement?id=' + data.code+"&type=publish", $rightappView);
			},
			renderComplete:function(){
				if (linkPublishId) {
					$pubThemeTree.gtree("expand", linkPublishId);
				}
				expandPubFirst();
			}
		});
	};

	

	var expandPubFirst = function(){
		if ($pubSearchBar.searchbar("getValue").trim() == ""){
			$pubThemeTree.gtree("expand", "share");
			$pubThemeTree.gtree("expand", "-1");
		}
	}
	var treeSelectIconChange=function(item,that,nodeData,type){
		var iconType;
		if(type=="public"){
			if(nodeData.type == 'visual'){
				iconType='visual'
			}else{
				iconType='folder'
			}
		}
		if(type=="theme"){
			if(nodeData.fileType=='FILE'&& nodeData.type=='visual'){
				iconType='visual'
			}else{
				iconType='folder'
			}
		}
		if(that.find(".tempo-icon-select").length>0 ){
			that.find(".tempo-icon-select").removeClass("tempo-api-icon-tree-16-position-10-selected");
			that.find(".tempo-icon-select").removeClass("tempo-ui-icon-api-folder-open-selected");
			that.find(".tempo-icon-select").removeClass("tempo-ui-icon-api-folder-close-selected");
			that.find("tempo-icon-select").removeClass("tempo-icon-select");
	    }
		if(iconType=='visual'){
			item.find("span:eq(0)").addClass("tempo-api-icon-tree-16-position-10-selected")	;
			item.find("span:eq(0)").addClass("tempo-icon-select");
		}
		if(iconType== 'folder'){
			if(item.find("span:eq(0)").hasClass("tempo-ui-icon-api-folder-close")){
				item.find("span:eq(0)").addClass("tempo-icon-select");
				item.find("span:eq(0)").addClass("tempo-ui-icon-api-folder-open-selected");
			}else{
				item.find("span:eq(0)").addClass("tempo-icon-select");
				item.find("span:eq(0)").addClass("tempo-ui-icon-api-folder-close-selected");
			}
		}
	
		
	}
	
	 var getContextMenu = function(itemData, level){
		 var menuMapping = {};
		 function render(type, level){
			 var menu = getPubMenu(type, level); 
			 var contextmenu = $("<ul class='tempo-app-tree-menu'/>").appendTo($("body")).contextmenu({
				 data: menu,
				 select:function(e,ui){ 
					 menuHandle.call(this, e, ui);
				 } 
			 });
			 menuMapping[type + level] = contextmenu;
		 };
		 return function(itemData, level){
			 var type = itemData.type;
			 if(menuMapping[type + level]){
				 return menuMapping[type + level];
			 }
			 render(type, level);
			 return menuMapping[type + level];
		 }
	 }();
	 
	 var getPubMenu = function(type, level){
		 var menus = getMenus();
		 var m;
		 if (type == "folder") {
			 if (isCGGLY && isSJRY) {
				 m = ['createFolder','createTheme','importTheme', "renameFolder", 'deleteFolder'];
				 if (level == 0) {
					m.splice(3, 2);
				}
				if (level > 1) {
					m.splice(0, 1);
				}
			 } else if (isCGGLY){
				 m = ['createFolder', "renameFolder", 'deleteFolder'];
				 if (level == 0) {
					m.splice(1, 2);
				}
				 if (level > 1) {
					m.splice(0, 1);
				}
			 } else {
				 m = ['createTheme','importTheme'];
			 }
		 }else if(type=="rootnode"){
			 m = ['createFolder','createTheme','importTheme'];
			 
		 } else {
			m = ['edit','copy','export','move','delete','rename'];
		 }
		 var showMenus = [];
		 for (var i=0;i<menus.length;i++){
			if (m.indexOf(menus[i].id) > -1){
				showMenus.push(menus[i]);
			}
		}
		 return showMenus;
	 }
	 
	 var menuHandle = function(e, ui){
		var data = ui.linkEl.data;
		var menuId = ui.select.id;
		switch (menuId) {
			case "createFolder" : 
				createFolder(data);
				break;
			case "renameFolder" : 
				renamePubFolder(data);
				break;
			case "deleteFolder" :
				deletePubFolder(data);
				break;
			case "createTheme" :
				createTheme(data);
				break;
			case "importTheme" :
				importTheme(data, false);
				break;
			case "copy" :
				copyPubTheme(data);
				break;
			case "export" :
				exportTheme(data);
				break;
			case "move" :
				movePubTheme(data);
				break;
			case "delete" :
				deleteTheme(data.id, true);
				break;
			case "edit" :
				editTheme(data);
				break;
			case "rename" :
				renamePubTheme(data);
				break;
		}
	 }
	 
	 var createPubFolder = function(data){
		var folderName = "";
		// 根目录
		if(data.parentId == null){
			pid = -1;
		}else{
			pid = data.id;
		}
	    if ( data.length>0&&$pubThemeTree.gtree("getNodeLevel", data.id) > 1){
			$("<div/>").alert({
				width:alertDialogWidth,
				height:alertDialogHeight,
				msg:TempoUtils.locale("bidesign.folder_max_level")
			});
			return;
		}
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append("<div class='tempo-strap-dialog-info-row'><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bi.base_name")+"</label><input class='tempo-strap-dialog-info-input' type='text' id='createFolder'></div>");
		dialog.dialog({
			modal : true,
			width : 500,
			height : 197,
			resizable : false,
			title : TempoUtils.locale("bidesign.new_folder"),
			open:function(){
				dialogValiDateBoxUtil(dialog,"#createFolder","resource.name_valid_tip");
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!dialog.find("#createFolder").validatebox("doValidate")){
						return;
					}
					folderName = dialog.find("input").val().trim();
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/folder/create',
						method: 'POST',
						data: {
							parentId: pid,
							name: folderName,
							workSpaceId:$(".theme-container").attr('workspaceid')
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.new_folder_fail")
								});
								return;
							}
							dialog.dialog("destroy").remove();
							$pubThemeTree.gtree('addItem', result.data, result.data.id);
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			} ,{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			}],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
	 }
	 
	 var renamePubFolder = function(data){
		 var folderName = data.name||"";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append("<div class='tempo-strap-dialog-info-row'><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bi.base_name")+"</label><input class='tempo-strap-dialog-info-input' type='text' id='createFolder'/></div>");
		dialog.dialog({
			modal : true,
			width : 500,
			height : 197,
			resizable : false,
			title : TempoUtils.locale("bidesign.rename_folder"),
			open:function(){
				dialogValiDateBoxUtil(dialog,"#createFolder","resource.name_valid_tip",folderName);
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!dialog.find("#createFolder").validatebox("doValidate")){
						return;
					}
					var newFolderName = dialog.find("input").val().trim();
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/resource/pub-folder/rename',
						method: 'POST',
						data: {
							id: data.id,
							name: newFolderName
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.rename_folder_fail")
								});
								return;
							}
							data.name = newFolderName;
							$pubThemeTree.gtree("updateItemName",data.id,newFolderName);
							dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
	 }
	 
	 var deletePubFolder = function(data){
		 if(data.parentId == null){
			failTip(TempoUtils.locale("bidesign.root_folder_abandon_delete"));
			return;
		}
		if ($pubThemeTree.gtree("getChildren", data).length > 0){
			failTip(TempoUtils.locale("bidesign.full_folder_abandon_delete"));
			return;
		}
		var id = data.id;
		$("<div>").confirm({
			width:alertDialogWidth,
			height:alertDialogHeight,
			msg:TempoUtils.locale("bi.parameter_confirm_remove"),
			ok:function(){
				var process = $("<div/>").tempoprogressbar();
				$.ajax({
					url: contextPath + '/api/resource/pub-folder/delete',
					method: 'POST',
					data: {
						id: id,
					}, 
					success: function(result) {
						if (!$.getters("success", result)){
							$("<div/>").alert({
								msg:$.getters("message", result)||TempoUtils.locale("bidesign.delete_folder_fail")
							});
							return;
						}
						$pubThemeTree.gtree('removeItem', id);
					}
				}).done(function(){
					process.tempoprogressbar("destroy");
				});
			}
		});
	 }
	 
	 var createPubTheme = function(data){
		var folderId = data.id;
		var themeName = "";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		var divHtml = renameThemeUtils.generateRenameThemeHtml();
		dialog.append(divHtml);
		dialog.dialog({
			modal : true,
			width : 500,
			height : 260,
			resizable : false,
			title : TempoUtils.locale("bidesign.new_theme"),
			open:function(){
				renameThemeUtils.renderHtml(dialog, {});
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!renameThemeUtils.valid(dialog)){
						return;
					}
					var formData = renameThemeUtils.getValue(dialog);
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/pub-analyse/create',
						method: 'POST',
						data: {
							folderId: folderId,
							name:formData.name,
							description:formData.description,
							workSpaceId:data.workSpaceId
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.new_theme_fail")
								});
								return;
							}
							$pubThemeTree.gtree('addItem', result.data, folderId);
							dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
	}
	 
	 var renamePubTheme = function(data){
		var id = data.id;
		var name = data.name;
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-rename'
		});
		var divHtml = renameThemeUtils.generateRenameThemeHtml();
		dialog.append(divHtml);
		dialog.dialog({
			modal : true,
			width : 500,
			height : 260,
			resizable : false,
			title : TempoUtils.locale("bi.base_rename"),
			open:function(){
				renameThemeUtils.renderHtml(dialog, data);
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!renameThemeUtils.valid(dialog)){
						return;
					}
					var formData = renameThemeUtils.getValue(dialog);
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/pub-analyse/update',
						method: 'POST',
						data: {
							id: id,
							name:formData.name,
							description:formData.description
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.edit_theme_fail")
								});
								return;
							}
							data.description = formData.description;
							data.name = formData.name;
							$pubThemeTree.gtree("updateItemName",id,formData.name);
							$("#tempo-header-themName").text(formData.name).attr("title",formData.name);
							dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
	}
	 
	 var copyPubTheme = function(data){
			var process = $("<div/>").tempoprogressbar();
			$.ajax({
				url: contextPath + '/api/bi/resource/pub-analyse/copy',
				method: 'POST',
				data: {
					id: data.id,
					folderId: data.parentId
				}, 
				complete: function(XMLHttpRequest, textStatus){
					process.tempoprogressbar("destroy");
				},
				success: function(result) {
					var data = result.data;
					$pubThemeTree.gtree('addItem', data, data.parentId);
				}
			});
		}
	 
	 var movePubTheme = function(data){
		curFolderId = "";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append(generateTreeEl());
		dialog.dialog({
			modal : true,
			width : 500,
			height : 400,
			resizable : false,
			title : TempoUtils.locale("bidesign.move"),
			buttons : [ {
				type : "ok",
				click : function() {
					if(curFolderId!=""){
						var folderId = curFolderId;
						if (folderId == data.parentId) {
							dialog.dialog("destroy").remove();
							return
						}
						var process = $("<div/>").tempoprogressbar();
						$.ajax({
							url: contextPath + '/api/bi/resource/pub-analyse/move',
							method: 'POST',
							data: {
								id: data.id,
								folderId: folderId
							}, 
							success: function(result) {
								if (!$.getters("success", result)){
									$("<div/>").alert({
										msg:$.getters("message", result)||TempoUtils.locale("bidesign.move_theme_fail")
									});
									return;
								}
								dialog.dialog("destroy").remove();
								$pubThemeTree.gtree('moveItem', data.id, curFolderId);
							}
						}).done(function(){
							process.tempoprogressbar("destroy");
						});
					}else{
						failTip(TempoUtils.locale("bidesign.select_target_folder"));
					}
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
		// 加载树
		var process = $("<div/>").tempoprogressbar();
		$.ajax({
			url: contextPath + '/api/resource/pub-folder/tree',
			method: 'get',
			data: {},
			success: function(data) {
				var treeData = data.data;
				var $folderTree = $("#folderTree");
				$folderTree.gtree({
					idKey : "id",
					textKey : 'name',
					multiSelect : false,
					data : treeData,
					expandFirst:true,
					isLeafNode:function(){
						return false;
					},
					getItemIcon:function(nodeData){
						return 'tempo-ui-icon-api-folder-close';
					},
					onSelect:function(data){
						curFolderId = data.id;
					},
					enableSelect:true,
					renderComplete:function(){
						$folderTree.gtree("expand", "-1");
					}
				});
			}
		}).done(function(){
			process.tempoprogressbar("destroy");
		});
	}
	 
	/**
	 * 初始化应用树
	 */
	var initExplorer = function(rootData) {
		if ($themeTree.hasClass("tempo-gtree")){
			$themeTree.gtree("destroy");
		}
		var menus = getMenus();
		$themeTree.gtree({
			url:contextPath + '/api/bi/resource/tree/list-own-analyse',
			enableSelect:true,
			rootData: rootData,
			beforeRequest:function(data){
				var param = {};
				if(data.sort==null||data.sort==""){
					data.sort=themeTreeSort;
				}
				if (!data || !data.id){
					param = {sort:data.sort};
				} else {
					param = {sort: data.sort, parentId:data.id};
				}
				param.searchWord = data.searchWord||"";
				param.workSpaceId = $('.theme-container').attr("workspaceid");
				return param;
			},
			getItemIcon:function(nodeData){
				if(nodeData.fileType == 'FILE') {
					return 'tempo-api-icon-tree-16 tempo-api-icon-tree-16-position-10';
				} else {
					return 'tempo-ui-icon-api-folder-close';
				}
			},
			onSelect:function(nodeData){
				var item = $(this);
				var that=$("#tempo-theme-tree")
				treeSelectIconChange(item,that,nodeData,'theme')
			},
			isLeafNode:function(nodeData){
				if(nodeData.fileType == 'FILE') {
					return true;
				} else {
					return false;
				}
			},
			nodeButtons:[{
				isShowNodeButtons:function(nodeData){
					if(!nodeData || nodeData.id == 'share'
							|| (!nodeData.fileType || nodeData.fileType == 'VIRTUAL_FOLDER')){
						return false;
					}
					return true;
				},
				click:function(nodeData, e){
					e.stopPropagation();
					var showMenus = [];
					var level = $themeTree.gtree("getNodeLevel", nodeData.id);
					var showMenuIds = beforeMenuShow(nodeData, level);
					if (!showMenuIds || showMenuIds.length == 0){
						return;
					}
					for (var i=0;i<menus.length;i++){
						if (showMenuIds.indexOf(menus[i].id) > -1){
							showMenus.push(menus[i]);
						}
					}
					if (showMenus.length == 0){
						return;
					}
					var contextmenu = $("<ul class='tempo-gtree-menu'/>").appendTo($("body")).contextmenu({
						data: showMenus,
						select:function(e,ui){ 
							var d = ui.linkEl.data;
							var menuId = ui.select.id;
							switch(menuId){
								// 文件夹
								case "createFolder" : createFolder(d); break;
								case "renameFolder" : renameFolder(d); break;
								case "deleteFolder" : deleteFolder(d); break;
								case "createTheme" : createTheme(d); break;
								case "importTheme" : importTheme(d); break;
								case "copy" : copyTheme(d); break;
								case "copyTo" : copyTo(d); break;
								case "export" : exportTheme(d); break;
								case "move" : moveTheme(d); break;
								case "delete" : deleteTheme(d.id); break;
								case "removePrivilege" : removePrivilege(d); break;
								case "edit" : editTheme(d); break;
								case "rename" : renameTheme(d); break;
							}
						} ,
						close:function(){
							contextmenu.remove();
						}
					});
					var offset = $(this).offset();
					var top = offset.top;
					var menuHeight = contextmenu.outerHeight();
					if(top + menuHeight > window.innerHeight){
						top = top - menuHeight;
					}
					contextmenu.contextmenu("show",{
						position:{
							left: offset.left + $(this).width()/2 + 7,
							top: top
						},
						linkEl:{
							data: nodeData
						}
					});
				}
			}],
			onItemClick:  function(data) {
				$rightappView.show();
				$rightdesignView.hide();
				$rightappView.empty();
				loadThemeView(data);
				
			},
			renderComplete:function(){
				if (analyse) {
					$themeTree.gtree("expand", analyse.id);
				}
				expandFirst();
			},
			loadComplete:function(resultData){
				if (!$.getters("success", resultData)){
					$("<div/>").alert({
						width:alertDialogWidth,
						height:alertDialogHeight,
						msg:$.getters("message", resultData)||TempoUtils.locale("bidesign.query_theme_fail")
					});
					return [];
				}
				if(resultData.message == "true"){
					$("#tempo-create-project-btn").css("margin-left","28px");
					$("#tempo-appInstall-project-btn").show();
				}else{
					$("#tempo-appInstall-project-btn").hide();
				}
				return resultData.data||[];
			}
		});
	};
	
		var loadThemeView=function(data){
		$rightappView.show();
		$rightdesignView.hide();
		$rightappView.empty();
		$m.loadPage(contextPath + '/api/bi/design/view/themeDetails?id=' + data.id+"&workSpaceId="+workSpaceId, $rightappView);
	}
	
	// 文件夹相关操作
	var createFolder = function(data){
		var folderName = TempoUtils.locale("bidesign.folder_name");
		var pid = "";
		// 根目录
		if($themeContainer.attr("workspacetype")=='self'){
		
			if(data.parentId == null){
				data.id= -1;
				pid = -1;
			}
			pid = data.id;
		}else{
		   if(data.parentId == null){
			    pid = -1;
	  	  }else{
			  pid = data.id;
		  }
	  }
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate tempo-theme-folder-operate'
		});
		dialog.append("<div class='tempo-strap-dialog-info-row'><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bi.base_name")+"</label><input class='tempo-strap-dialog-info-input' type='text' id='createFolder'></div>");
		var height =197;
		if(pid=="-1"){
			height=400;
			dialog.append(generateTreeEl());
		}
		dialog.dialog({
			modal : true,
			width : 500,
			height : height,
			resizable : false,
			title : TempoUtils.locale("bidesign.new_folder"),
			open:function(){
				$.ajax({
					url: contextPath + '/api/bi/resource/folder/work-name',
					method: 'POST',
					data: {
						parentId:pid,
						prefix:folderName,
						workSpaceId: $('.theme-container').attr("workspaceid")
					}, 
					success: function(result) {
						dialogValiDateBoxUtil(dialog,"#createFolder","resource.name_valid_tip",result.data);
					}
				});
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!dialog.find("#createFolder").validatebox("doValidate")){
						return;
					}
					folderName = dialog.find("input").val().trim();
					var $folderTree = $("#folderTree");
					var fid=$folderTree.gtree("getSelected").id;
					if ($folderTree.gtree("getNodeLevel", fid) >= 2){
						$("<div/>").alert({
							width:alertDialogWidth,
							height:alertDialogHeight,
							msg:TempoUtils.locale("bidesign.folder_max_level")
						});
						return;
					}
					var process = $("<div/>").tempoprogressbar();
					var parentId= pid=="-1"?fid:pid
					$.ajax({
						url: contextPath + '/api/bi/resource/folder/create',
						method: 'POST',
						data: {
							parentId:parentId,
							name:folderName,
							workSpaceId: $('.theme-container').attr("workspaceid")
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.new_folder_fail")
								});
								return;
							}
							dialog.dialog("destroy").remove();
							result.data.fileType = 'FOLDER';
							if($themeContainer.attr("workspacetype")=='self'){
								 $themeTree.gtree('addItem', result.data, parentId);
							}else{
								 $themeTree.gtree('addItem', result.data, parentId=="-1"?null:parentId);
							}
						   
						    
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			} ,{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			}],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
		openTree(dialog);
		
}
	
	var renameFolder = function(data){
		var folderName = data.name||"";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append("<div class='tempo-strap-dialog-info-row'><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bi.base_name")+"</label><input class='tempo-strap-dialog-info-input' type='text' id='createFolder'/></div>");
		dialog.dialog({
			modal : true,
			width : 500,
			height : 197,
			resizable : false,
			title : TempoUtils.locale("bidesign.rename_folder"),
			open:function(){
				dialogValiDateBoxUtil(dialog,"#createFolder","resource.name_valid_tip",folderName);
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!dialog.find("#createFolder").validatebox("doValidate")){
						return;
					}
					var newFolderName = dialog.find("input").val().trim();
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/folder/rename',
						method: 'POST',
						data: {
							id: data.id,
							name:newFolderName,
							workSpaceId:$('.theme-container').attr("workspaceid")
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.rename_folder_fail")
								});
								return;
							}
							data.name = newFolderName;
							$themeTree.gtree("updateItemName",data.id,newFolderName);
							if($pubThemeTree.data("tempo-gtree")){
								$pubThemeTree.gtree("updateItemName",data.id,newFolderName);
							}
							dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});;
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});

	}

	var deleteFolder = function(data){
		var isAdmin = false;
		$.ajax({
			url : contextPath + ('/api/workspace/workspace-Admin'),
			type : 'post',
			data:{
				id: $('.theme-container').attr("workspaceid")
			},
			async:false,
			dataType : 'json',
			success : function(result) {
				var objs = result.data;
				for(var i=0;i<objs.length;i++){
					if(objs[i].usercode==currentUserId){
						if(objs[i].type == 1){
							isAdmin = true;
						}
			    	}
				}
			} 
		});
		if(!isAdmin){
			if(!$.isEmptyObject(data.creator)){
				if(data.creator != currentUserId){
					failTip(TempoUtils.locale("bidesign.user_folder_auth"));
					return;
				}
			}else{
				if(data.userId != currentUserId){
					failTip(TempoUtils.locale("bidesign.user_folder_auth"));
					return;
				}
			}
		}
		if(data.parentId == null){
			failTip(TempoUtils.locale("bidesign.root_folder_abandon_delete"));
			return;
		}
		if ($themeTree.gtree("getChildren", data).length > 0){
			failTip(TempoUtils.locale("bidesign.full_folder_abandon_delete"));
			return;
		}
		var folderid = data.id;
		$("<div>").confirm({
			width:alertDialogWidth,
			height:alertDialogHeight,
			msg:TempoUtils.locale("bi.parameter_confirm_remove"),
			ok:function(){
				var process = $("<div/>").tempoprogressbar();
				$.ajax({
					url: contextPath + '/api/bi/resource/folder/delete',
					method: 'POST',
					data: {
						id: folderid,
					}, 
					success: function(result) {
						if (!$.getters("success", result)){
							$("<div/>").alert({
								msg:$.getters("message", result)||TempoUtils.locale("bidesign.delete_folder_fail")
							});
							return;
						}
						$themeTree.gtree('removeItem', folderid);
					}
				}).done(function(){
					process.tempoprogressbar("destroy");
				});;
			}
		});
		
	}

	var createTheme = function(data){
		var folderId = "";
		var themename = TempoUtils.locale("bidesign.new_theme_name");
		if($themeContainer.attr("workspacetype")=='self'){
			if(data.parentId == null){
				data.id= -1;
				folderId = -1;
			}
			folderId = data.id;
		}else{
			if(data.parentId == null){
				folderId = -1;
			}else{
				folderId = data.id;
			}
		}
		var themeName = "";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate tempo-create-folder-operate'
		});
		var divHtml = renameThemeUtils.generateRenameThemeHtml();
		dialog.append(divHtml);
		var height =260;
		if(folderId=="-1"){
			height=440;
			dialog.append(generateTreeEl());
		}
		dialog.dialog({
			modal : true,
			width : 500,
			height : height,
			resizable : false,
			title : TempoUtils.locale("bidesign.new_theme"),
			open:function(){
				var formData = renameThemeUtils.getValue(dialog);
				var process = $("<div/>").tempoprogressbar();
				var parentId = data.parentId == null ? "-1" : data.id;
				$.ajax({
					url: contextPath + '/api/bi/resource/analyse/list-allapp',
					method: 'POST',
					data: {
						folderId: parentId,
						prefix:themename,
						description:formData.description,
						workSpaceId:$('.theme-container').attr("workspaceid")
					}, 
					success: function(result) {
						dialogValiDateBoxUtil(dialog,"#themeName","resource.name_valid_tip",result.data);
					}
				})
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!renameThemeUtils.valid(dialog)){
						return;
					}
					var formData = renameThemeUtils.getValue(dialog);
					var $folderTree = $("#folderTree");
					var fid=$folderTree.gtree("getSelected").id;
					var process = $("<div/>").tempoprogressbar();
					var parentId= folderId=="-1"?fid:folderId
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/analyse/create',
						method: 'POST',
						data: {
							folderId: parentId,
							name:formData.name,
							description:formData.description,
							workSpaceId:$('.theme-container').attr("workspaceid")
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.new_theme_fail")
								});
								return;
							}
							result.data.fileType = 'FILE';
							result.data.belong='1';
							// 父id需要重新赋值，这里取folderId
							result.data.parentId = result.data.folderId;;
							var nodelevel=$folderTree.gtree("getNodeLevel", fid);
							if(nodelevel==2){
								var data=$folderTree.gtree('getItemData', fid);
								var $item = $themeTree.find("div[_itemid='"+data.parentId+"']");
								var isopen = $item.find("span").hasClass("tempo-gtree-open-folder-flag")
								if(!isopen){
									$themeTree.gtree('clickItem', data.parentId);
								}
							}
							if($themeContainer.attr("workspacetype")=='self'){
								$themeTree.gtree('addItem', result.data,parentId);
							}else{
								$themeTree.gtree('addItem', result.data,parentId=="-1"?null:parentId);
							}
							
							$themeTree.gtree('clickItem', result.data.id);
						    editTheme(result.data);
						    dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
			openTree(dialog);
}
	var importTheme = function(data, isPub){
		isPub = !!isPub;
		theme.importFolder = data;
		theme.isPub = isPub;
		var workSpaceType = $themeContainer.attr("workspacetype");
		data['workSpaceType'] = workSpaceType;
		Eventbus.trigger("importExportHandler.temporesource", data, 'import', isPub,workSpaceId);
	}

	var copyTheme = function(data){
		var process = $("<div/>").tempoprogressbar();
		$.ajax({
			url: contextPath + '/api/bi/resource/analyse/copy',
			method: 'POST',
			data: {
				id: data.id,
				folderId: data.parentId==null?'-1':data.parentId
			}, 
			complete: function(XMLHttpRequest, textStatus){
				process.tempoprogressbar("destroy");
			},
			success: function(result) {
				result.data.fileType = 'FILE';
				result.data.belong='1';
				result.data.parentId = result.data.folderId;
				var pid = data.parentId;
				if(pid=="-1"||pid==null){
					$themeTree.gtree('reload');
				}else{
					$themeTree.gtree('reloadItem',pid);
				}
			}
		});
	}

	var exportTheme = function(data){
		Eventbus.trigger("importExportHandler.temporesource", data, 'export');
	}

	var moveTheme = function(data){
		curFolderId = "";
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append(generateTreeEl());
		dialog.dialog({
			modal : true,
			width : 500,
			height : 400,
			resizable : false,
			title : TempoUtils.locale("bidesign.move"),
			buttons : [ {
				type : "ok",
				click : function() {
					if(curFolderId!=""){
						var resourceId = curFolderId;
						var process = $("<div/>").tempoprogressbar();
						$.ajax({
							url: contextPath + '/api/bi/resource/analyse/move',
							method: 'POST',
							data: {
								id: data.id,
								folderId:resourceId,
								workSpaceId:workSpaceId
							}, 
							success: function(result) {
								if (result && result.success){
									dialog.dialog("destroy").remove();
									$themeTree.gtree('reload');
								}else{
									moveFailTip(result.message);
								}
							}
						}).done(function(){
							process.tempoprogressbar("destroy");
						});
					}else{
						failTip(TempoUtils.locale("bidesign.select_target_folder"));
					}
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
		openTree(dialog);
	}
	
	var moveFailTip = function(msg){
		$("<div/>").alert({
			msg : msg,
		});
	}
	
	var copyTo = function(data){
		curFolderId = "";
		curworkSpaceId = workSpaceId;
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		var dialogel = "<div class='tempo-strap-dialog-tree-container'>" +
							"<select id='workSpaceList' style='left:65%;' ></select>" +
					   		"<div id='folderTree' style='height:80%;margin-top:15px;'class='tempo-strap-dialog-tree'></div>" +
					   "</div>";
		dialog.append(dialogel);
		dialog.dialog({
			modal : true,
			width : 500,
			height : 400,
			resizable : false,
			title : TempoUtils.locale("bi.base_copy"),
			buttons : [ {
				type : "ok",
				click : function() {
					if(curFolderId!=""){
						var resourceId = curFolderId;
						var process = $("<div/>").tempoprogressbar();
						$.ajax({
							url: contextPath + '/api/bi/resource/analyse/copy',
							method: 'POST',
							data: {
								id: data.id,
								folderId:resourceId,
								workSpaceId:curworkSpaceId
							}, 
							success: function(result) {
								if (!$.getters("success", result)){
									$("<div/>").alert({
										msg:$.getters("message", result)||TempoUtils.locale("bidesign.copy_theme_fail")
									});
									return;
								}
								dialog.dialog("destroy").remove();
								if(curFolderId=="-1"||curFolderId==null){
									$themeTree.gtree('reload');
								}else{
									$themeTree.gtree('reloadItem',curFolderId);
								}
							}
						}).done(function(){
							process.tempoprogressbar("destroy");
						});
					}else{
						failTip(TempoUtils.locale("bidesign.select_target_folder"));
					}
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
		openTree(dialog);
		createWorkSpaceList(dialog);
	}
	
	var createWorkSpaceList =  function(dialog){
		var data = getWorkSpaceList();
		var $selectmenu = dialog.find("#workSpaceList");
		for (var i = 0; i < data.length; i++) {
			$("<option>",{
				"value":data[i].id,
				"text":data[i].text
			}).appendTo($selectmenu);
		}
		$selectmenu.selectmenu({
			change:function(e,element){
				curworkSpaceId = element.item.value;
				var process = $("<div/>").tempoprogressbar();
				$.ajax({
					url: contextPath + '/api/bi/resource/tree/list-own-folder',
					method: 'POST',
					data: {
						sort: 'ASC',
						workSpaceId:curworkSpaceId
					},
					success: function(data) {
						var treeData = dataProcess(data.data[0]);
						treeData = [treeData];
						var $folderTree = $("#folderTree");
						$folderTree.gtree({
							data : treeData
						});
						$folderTree.gtree("reload");
					}
				}).done(function(){
					process.tempoprogressbar("destroy");
				});
			}
		});
		$selectmenu.val(workSpaceId).selectmenu('refresh');
		$('#workSpaceList-menu li').width(150);
	}
	var generateTreeEl = function(){
		return "<div class='tempo-strap-dialog-tree-container'><div id='folderTree' class='tempo-strap-dialog-tree'></div></div>";
	}
	
	var openTree = function(dialog){
		var process = $("<div/>").tempoprogressbar();
		$.ajax({
			url: contextPath + '/api/bi/resource/tree/list-own-folder',
			method: 'POST',
			data: {
				sort: 'DEFAULT',
				workSpaceId:workSpaceId
			},
			success: function(data) {
				var treeData = dataProcess(data.data[0]);
				treeData = [treeData];
				var $folderTree = $("#folderTree");
				$folderTree.gtree({
					idKey : "id",
					textKey : 'name',
					multiSelect : false,
					data : treeData,
					expandFirst:true,
					isLeafNode:function(){
						return false;
					},
					getItemIcon:function(nodeData){
						return 'tempo-ui-icon-api-folder-close';
					},
					onSelect:function(data){
						curFolderId = data.id;
					},
					enableSelect:true,
					renderComplete:function(){
						$folderTree.gtree("expand", "-1");
					}
				});
			}
		}).done(function(){
			process.tempoprogressbar("destroy");
		});
	}

	var dataProcess=function(data) {
		if($.isArray(data)) {
			for(var i in data) {
				dataProcess(data[i]);
			}
		} else {
			data.title = data.name;
			data.icon = 'ui-icon tempo-ui-icon tempo-ui-icon-no-mutual ';
			if(data.fileType == 'FILE') {
				data.icon += 'tempo-ui-icon-scene';
			} else if(data.fileType == 'FOLDER') {
				data.icon += 'tempo-ui-icon-api-folder-close';
				data.groupType = 'folder';
				data.type = 'group';
			} else {
				data.groupType = 'folder';
				data.type = 'group';
				data.icon += 'tempo-ui-icon-api-folder-close';
			}
			if(data.children && data.children.length) {
				dataProcess(data.children);
			}
		}
		return data;
	}

	var deleteTheme = function(id, isPub){
		$("<div>").confirm({
			width:alertDialogWidth,
			height:alertDialogHeight,
			msg:TempoUtils.locale("bi.parameter_confirm_remove"),
			ok:function(){
				var process = $("<div/>").tempoprogressbar();
				$.ajax({
					url: contextPath + '/api/bi/resource/analyse/delete',
					method: 'POST',
					data: {
						id: id,
					}, 
					success: function(result) {
						if (!$.getters("success", result)){
							$("<div/>").alert({
								msg:$.getters("message", result)||TempoUtils.locale("bidesign.delete_theme_fail")
							});
							return;
						}
						if (!!isPub) {
							$pubThemeTree.gtree('removeItem', id);
						
						} else {
							$themeTree.gtree('removeItem', id);
							cleanRightConteiner();
						}
					}
				}).done(function(){
					process.tempoprogressbar("destroy");
				});
			}
		});
	}
	
	var removePrivilege = function(data){
		$("<div>").confirm({
			width:alertDialogWidth,
			height:alertDialogHeight,
			msg:TempoUtils.locale("bidesign.confirm_to_remove"),
			ok:function(){
				var process = $("<div/>").tempoprogressbar();
				$.ajax({
					url: contextPath + '/api/resource/permission/revoke-by-all',
					method: 'POST',
					data: {
						resId: data.id,
						users: currentUserId
					}, 
					success: function(result) {
						$themeTree.gtree("removeItem",data.id);
						var children = $themeTree.gtree("getChildren",{id:data.userId});
						if (!children || children.length == 0){
							$themeTree.gtree("removeItem",data.userId);
						}
					}
				}).done(function(){
					process.tempoprogressbar("destroy");
				});
			}
		});
	}

	var renameTheme = function(data){
		var id = data.id;
		var name = data.name;
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-rename'
		});
		var divHtml = renameThemeUtils.generateRenameThemeHtml();
		dialog.append(divHtml);
		dialog.dialog({
			modal : true,
			width : 500,
			height : 260,
			resizable : false,
			title : TempoUtils.locale("bi.base_rename"),
			open:function(){
				renameThemeUtils.renderHtml(dialog, data);
			},
			buttons : [ {
				type : "ok",
				click : function() {
					if(!renameThemeUtils.valid(dialog)){
						return;
					}
					var formData = renameThemeUtils.getValue(dialog);
					var process = $("<div/>").tempoprogressbar();
					$.ajax({
						url: contextPath + '/api/bi/resource/analyse/update',
						method: 'POST',
						data: {
							id: id,
							name:formData.name,
							workSpaceId:workSpaceId,
							description:formData.description
						}, 
						success: function(result) {
							if (!$.getters("success", result)){
								$("<div/>").alert({
									width:alertDialogWidth,
									height:alertDialogHeight,
									msg:$.getters("message", result)||TempoUtils.locale("bidesign.edit_theme_fail")
								});
								return;
							}
							data.description = formData.description;
							data.name = formData.name;
							$themeTree.gtree("updateItemName",id,formData.name);
							if($pubThemeTree.data("tempo-gtree")){
								$pubThemeTree.gtree("updateItemName",id,formData.name);
							}
							$("#tempo-header-themName").text(formData.name).attr("title",formData.name);
							dialog.dialog("destroy").remove();
						}
					}).done(function(){
						process.tempoprogressbar("destroy");
					});
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				// 销毁弹出框,并返回
				dialog.dialog("destroy").remove();
			}
		});
	}
	
	var failTip = function(msg){
		var dialog = $("<div/>", {
			'class' : 'tempo-theme-operate'
		});
		dialog.append("<div style='text-align:center;width:100%;height:100%;'><div class='tipinfo'>"+msg+"</div></>");
		dialog.dialog({
			modal : true,
			width : 400,
			height : 170,
			resizable : false,
			title : TempoUtils.locale("bi.base_tooltip"),
			buttons : [ {
				type : "ok",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			},{
				type : "cancel",
				click : function() {
					dialog.dialog("destroy").remove();
				}
			} ],
			close : function() {
				dialog.dialog("destroy").remove();
			}
		});
	}
	
	var editTheme = function(data) {
		var id = data.id;
		var sceneId = getCurSceneId(id);
		var url = "/api/bi/resource/analyse/view/index?id=" + id;
		if (sceneId) {
			url += "&sceneId=" + sceneId;
		}
		try{
			// if (window.parent.topDialog){
			// 	window.parent.topDialog(null,contextPath + url, function(frame) {
			// 		if(frame.$('.tempo-story-tabs .tempo-story-tab-change').length) {
			// 			return TempoUtils.locale("bidesign.un_save_promot");
			// 		}
			// 		return null;
			// 	}, function(iframe,treeSlectId) {
			// 		// 发布、取消发布后通知已发布场景数量刷新
			// 		var $sceneBoard=$("#tempo-theme-detail-view-layout").find('.blackboard');
			// 		Eventbus.trigger("publishNum.theme",null);
			// 		if(treeSlectId){
			// 			Eventbus.trigger("treeSelect.theme",treeSlectId)
			// 		}
			// 		$sceneBoard.attr('src', $sceneBoard.attr('src'));
			// 	},function(frame,iframe,themeId,dialog){
			// 		var window=iframe[0].contentWindow;
			// 		var selectTab=window.$(".tempo-story-tabs").find(".tempo-story-tab-curSelect");
			// 		var selectedId = selectTab.attr("linkid");
			// 		var src=contextPath+"/api/bi/resource/analyse/view/index?id=" + themeId;;
			// 		if(selectedId){
			// 			src += "&selectedId=" + selectedId;
			// 		}
			// 		var data=window.$(".tempo-story-tabs").find(".tempo-story-tab-curSelect").data();
			// 		dialog.find('iframe').attr('src', src);
			// 	});
			// } else {
				window.open(contextPath + url, "_blank");
			//}
		}catch(e){
			window.open(contextPath + url, "_blank");
		}
	};
	
	/**
	 * 获取当前选中的场景id及类型
	 */
	var getCurSceneId = function(themeId){
		var sceneId = null;
		var $sceneBoard=$("#tempo-theme-detail-view-layout").find('.blackboard');
		if (themeId != $sceneBoard.attr("_subjectId")){
			return sceneId;
		}
		if (!$sceneBoard[0].contentDocument){
			return sceneId;
		}
		var selectTab = $($sceneBoard[0].contentDocument).find(".tempo-story-tab-curSelect");
		if (selectTab.length == 0){
			return sceneId;
		}
		var sceneId = selectTab.attr("linkid");
		return sceneId;
	}

	this.init = function() {
		layout();
		setWorksapceList.init();
		initTabs();
		initSearchbar();
		addThemeToobarSelectClass($editBtn);
	    initBtnClick();
	    initEventBus();
	    initTreeSortButton();
		// 选中第一个
		$themeTabs.children("li:first-child").trigger("click");
	};
	/**
	 * 初始化Eventbus
	 */
	var initEventBus = function(){
		//新建应用之后通知编辑应用
		Eventbus.bind("editTheme.theme",editTheme,this);
	    // 发布或者取消发布重新刷发布区的树
		// 设计区发布操作通知
		Eventbus.bind("publish.theme",themePublish,this);
		// 设计区取消发布操作通知
		Eventbus.bind("unPublish.theme",themeUnPublish,this);
		// 同步操作通知
		Eventbus.bind("sync.theme",themeSync,this);
		// 头部名称重命名操作通知
		Eventbus.bind("updateTopName.theme",updateItemName,this);
		// 点击已发布链接切换至发布区
		Eventbus.bind("tabsClick.theme",tabsClick,this);
		// 发布区取消发布，左侧树调整结构
		Eventbus.bind("cancelPublished.app",cancelPublished,this);
		// 发布区同步，左侧树该节点刷新
		Eventbus.bind("refreshItem.app",refreshItem,this);
		//应用树点击事件
		Eventbus.bind("treeSelect.theme",themecheck,this)
		
	}
	var themecheck=function(id){
		$themeTree.gtree("clickItem",id)
	}
	var refreshItem=function(id){
		$pubThemeTree.gtree("updateItem",id);
		$pubThemeTree.gtree("clickItem",id);
	}
	var cancelPublished=function(id){
		cleanRightConteiner();
		$pubThemeTree.gtree("removeItem",id);
	}
	var tabsClick=function(data){
		$themeTabs.children("li:last-child").trigger("click",data.id);
		searchWord = data.name;
		$pubSearchBar.searchbar("setValue", searchWord);
		linkPublishId=data.id;
		initPubTree({
			id : "-1",
			searchWord: searchWord,
			workSpaceId:workSpaceId,
			sort:themeTreeSort,
			searchThemeId:linkPublishId
		});
	}
	
	var updateItemName=function(data){
		renameThemeUtils.updateItemName(data.type,data.id,data.name)
	}
	var themePublish=function(theme){
		initPubTree({
			 id : "-1",
			 workSpaceId:workSpaceId,
		     sort:themeTreeSort
		   })
	}
	var themeUnPublish=function(theme){
		initPubTree({
			 id : "-1",
			 workSpaceId:workSpaceId,
		     sort:themeTreeSort
		   })
	  
	}
	var themeSync=function(itemId){
		 if ($pubThemeTree.data("tempo-gtree")) {
			 $pubThemeTree.gtree('selectItem', itemId);
			 $pubThemeTree.gtree('reloadItem', itemId);
         }
	}
    var initBtnClick=function(){	
    	$("#tempo-go-back-workspace").click(function(){
    		var thisUrl = contextPath + "/api/bi/resource/view/workspace?enterType=theme";
		    thisUrl = TempoUtils.addHideIconParam(thisUrl);
		     window.location.href = thisUrl;
    	})
    	
    	$("#tempo-create-project-btn").click(function(){
    		var data=[{
    			parentId:null
    		}]
    		createTheme(data)
    	})
    	$("#tempo-appInstall-project-btn").click(function(){
    		var data=[{
    			id:-1
    		}]
    		appInstall(data);
    	})
  		$("#createWorkspace").click(function(){
  		    var panelTabsSelect=$("#theme-menu-ul").find(".tempo-strap-panel-tabs-selected").attr("value");
  			if(panelTabsSelect=="theme_public"){
  				return ;
  			}
  			var data=[]
  			var $this = $(this);
  			var offset = $this.offset()
  			var contextMenu = getContextMenu({type:"rootnode"},0);
			var top = offset.top;
			var menuHeight = contextMenu.outerHeight();
			if(top + menuHeight > window.innerHeight){
				top = top - menuHeight;
			}
			contextMenu.contextmenu("show",{
				position:{
					left: offset.left + $this.width()/2 + 14,
					top: top
				},
				linkEl:{
					data: data
				}
			})
  		});
    	$('body').mouseout(function(e){
   	     if(!$(e.target).closest("#workspace-select,#tempo_workspace_index,#tempo_workspace_select").length){
   	        $(".workspace-ul").hide();
   	     }
        })
        $('body').click(function(e){
    	     if(!$(e.target).closest("#workspace-select,#tempo_workspace_index,#tempo_workspace_select").length){
    	        $(".workspace-ul").hide();
    	     }
         })
         $(".theme-more-info").off('click').on('click',function(){
 			themeDetail(theme.id);
 		});
    	
   }
    /**
	 * 初始化表排序
	 */
	var initTreeSortButton = function(){
		$treeSortPanel.unbind('click').bind('click',function(e){
			configMenuOperator.showMenus(e);
		});
	}
    
	/**
	 * 菜单的操作
	 */
	var configMenuOperator = {
		/**
		 * 显示菜单
		 */
		showMenus:function(event){
			var modelMenu = utils.initMenu(event,configMenuOperator.exeucteMenuFor);
			modelMenu.contextmenu('selectItem',themeTreeSort);
			
		},
	}
	var utils = {
			initMenu:function(event,selectCallBack,data,dealMenuStatusCallBack){
				var modelMenu = $("<ul/>").appendTo($("body"));
				modelMenu.css({
					"z-index":1000
				});
				var menuData = utils.getMenusData();
			    var panelTabsSelect=$("#theme-menu-ul").find(".tempo-strap-panel-tabs-selected").attr("value");
				modelMenu.contextmenu({
					data:menuData,
					show:true,
					selectable:true,
					select:function(e,ui){ 
						var d = ui.linkEl.data;
						var menuId = ui.select.id;
						 var data={
								id : "-1",
								workSpaceId:workSpaceId,
								sort:menuId,
								searchWord:(panelTabsSelect=="theme_private" ? $searchBar.searchbar("getValue").trim():$pubSearchBar.searchbar("getValue").trim())||""
								
						};
						 themeTreeSort=menuId;
						switch(menuId){
							// 文件夹
							case "DEFAULT" : 
								panelTabsSelect=="theme_private" ? initExplorer(data):initPubTree(data);
							    break;
							case "ASC" : 
								panelTabsSelect=="theme_private"? initExplorer(data):initPubTree(data);
								break;
							case "DESC" :
								panelTabsSelect=="theme_private"? initExplorer(data):initPubTree(data);
								 break;
						}
					} ,
					close:function(){
						modelMenu.remove();
					}
				});
				if(dealMenuStatusCallBack){
					dealMenuStatusCallBack.call(modelMenu,data);
				}
				var posiLeft = event.pageX-16;
				var posiTop = event.pageY+16;
				var screenHeight = window.innerHeight;
				var minus = screenHeight - event.pageY;
				var menuHeight = modelMenu.height();
				if(minus < menuHeight){
					posiTop = posiTop - menuHeight;
				}
				
				modelMenu.contextmenu("show",{
					position:{
						left:posiLeft,
						top:posiTop
					},
					linkEl:this
				});
				return modelMenu;
			},
			/**
			 * 获取菜单数据
			 */
			getMenusData:function(){
				var menuData = [{
					text:'默认排序',
					id:'DEFAULT'
				},{
					text:'名称顺序',
					id:'ASC'
				},{
					text:'名称倒序',
					id:'DESC'
				}]
				return menuData;
			},
	}
	
    var appInstall=function(data){
    	var process = $("<div/>").tempoprogressbar();
    	$.ajax({
			url: contextPath + '/appInstallController/createFolder',
			method: 'POST',
			data: {
				parentId: "-1",
				name:"案例集",
				workSpaceId: $('.theme-container').attr("workspaceid")
			}, 
			success: function(result) {
				if (!$.getters("success", result)){
					$("<div/>").alert({
						width:alertDialogWidth,
						height:alertDialogHeight,
						msg:$.getters("message", result)||TempoUtils.locale("bidesign.new_folder_fail")
					});
					return;
				}
			    $themeTree.gtree('addItem', result.data, data.id);
			    $.ajax({
					url: contextPath + '/appInstallController/appInstall',
					method: 'POST',
					data: {
						parentId: "-1",
						name:"案例集",
						workSpaceId: result.data.workSpaceId
					}, 
					success: function(result) {
						if (!result.flag){
							$("<div/>").alert({
								width:alertDialogWidth,
								height:alertDialogHeight,
								msg:result.errorMsg
							});
						}else{
							$("<div/>").alert({
								width:alertDialogWidth,
								height:alertDialogHeight,
								msg:result.message
							});
						}
						window.location.reload();
					}
				});
			}
		}).done(function(){
			process.tempoprogressbar("destroy");
		});
    }
    var createSelectLi=function(menus){
    	var $WorkspaceSelectDiv=$("#tempo_workspace_select");
		var $WorkspaceIndexDiv=$("#tempo_workspace_index");
    	for(var j=0;j<menus.length;j++){
			if(menus[j].id==workSpaceId){
				workspceName = menus[j].text;
			}
			$("<li>",{
				value:menus[j].id,
				text:_subString(menus[j].text,13),
			}).data('ds-item',menus[j]).attr('title',menus[j].text).appendTo($WorkspaceSelectDiv);
		};
		$("<li>",{
			'class':'workspace-index',
			value:'workspaceIndex',
			text:"空间管理",
		}).data('ds-item',menus[j]).appendTo($WorkspaceIndexDiv);
		
		
    }
    
   var getWorkSpaceList=function(){
	   var menus=[];
	   $.ajax({
			url : contextPath + ('/api/workspace/list'),
			type : 'post',
			data:{
				fType:fType
			},
			async:false,
			dataType : 'json',
			success : function(result) {
				var objs = result.data;
				for (var i = 0; i < objs.length; i++) {
					if(objs[i].ID==$themeContainer.attr("workspaceid")){
						$themeContainer.attr("workspacetype",objs[i].WORK_SPACE_TYPE);
					}
					menus.push({
						text:objs[i].NAME,
						id:objs[i].ID,
					})
				}
			} 
		});
    	return menus;
    }
   
    var _subString = function(str,length){
    	if(!str){
    		return str;
    	}
    	var  chRegex=/[^\x00-\xff]/g;
    	var newLength = 0;
    	var newStr ="";
    	var strLength = str.replace(chRegex,"**").length;
    	if(strLength<length){
    		return str;
    	}
    	for (var i = 0; i < strLength; i++) {
			var singleChar = str.charAt(i);
			if(singleChar.match(chRegex)!=null){
				newLength+=2;
			}else{
				newLength++;
			}
			if(newLength>length){
				break;
			}
			newStr+=singleChar;
		}
    	return newStr+="...";
    }
	/**
	 * 设置工作空间列表
	 */
	var setWorksapceList = (function(){
		var menus=getWorkSpaceList();
		$('#workspace-select').html('<ul id="tempo_workspace_index" class="workspace-ul"></ul>'+
				'<ul id="tempo_workspace_select" class="workspace-ul"></ul>');
		var $WorkspaceSelectDiv=$("#tempo_workspace_select");
		var $WorkspaceIndexDiv=$("#tempo_workspace_index");
		createSelectLi(menus);
		var contextMenu,click,init,select,workspceName;
		
		for(var j=0;j<menus.length;j++){
			if(menus[j].id==workSpaceId){
				workspceName = menus[j].text;

			}
		};
		var inputHtml="<input type='text' id='change_select' readonly unselectable='on' class='select-input'></input>"
		$WorkspaceIndexDiv.css({'top':$WorkspaceSelectDiv.height()});
		$('#workspace-select').append(inputHtml)
		$(".select-input").val(_subString(workspceName,14)).attr('title',workspceName);
		$("#change_select").on("click",function(){
		var thisul=$(".workspace-ul")
		var thisInput=$(".select-input")
		if($(".select-option").css('display')=="block"){
			$(".select-option").hide();
		}
		if(thisul.css('display')=="none"){
			$WorkspaceSelectDiv.find("li").remove();
			$WorkspaceIndexDiv.find("li").remove();
			createSelectLi(getWorkSpaceList());
			$WorkspaceIndexDiv.css({'top':$WorkspaceSelectDiv.height()+16});
		    thisul.show();
			thisul.find('li').click(function(){
				thisInput.val($(this).text());
				select($(this).attr('value'))
				thisul.hide();
			}).hover(function(){
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			});
			}else{
				thisul.hide();
			};
		});
		click = function(e){
			
		};
		select = function(id){
			var thisUrl = contextPath + "/api/"+(fType=="mining"?"ai":"bi")+"/resource/view/theme?workSpaceId=" + id;
			if(id=="workspaceIndex"){
				thisUrl = contextPath + "/api/"+(fType=="mining"?"ai":"bi")+"/resource/view/workspace?enterType=theme";
			}
			thisUrl = TempoUtils.addHideIconParam(thisUrl);
			window.location.href = thisUrl;
		}
		init = function(){
			$WorkspaceSelectDiv.bind("click",click);
		}
		return {
			init:init
		}
	})();
	
	
	
    
  var bannerText=function(type,value){
	    var bannerView =$("#tempo-banner-tooltip");
		if (type == "title"){
			bannerView.find(".tempo-firstlevel-tooltips").text(value);
		} else if (type == "desc"){
			bannerView.find(".item-first-desc").text(value);
		} else if (type == "nextDesc"){
			bannerView.find(".item-next-desc").text(value);
		} 
  }
    
	var initTabs = function(){
		// 如果是个人空间 ， 隐藏发布区
		var workSpaceType = $themeContainer.attr("workspacetype");
		if(workSpaceType == "self"){
			$("#theme-menu-ul").hide();
			$(".tempo-west-container").css("padding-top","15px");
			$(".tempo-strap-panel-tabs-content").css("height",'calc(100% - 86px)');
		}
		$themeTabs.on("click", "li", function(event,id){
			if ($(this).hasClass("ui-state-disabled")) {
				return
			}
			$(this).addClass("tempo-strap-panel-tabs-selected").siblings().removeClass("tempo-strap-panel-tabs-selected");
			var href = $(this).attr("_href");
			$(href).show().siblings(".tempo-strap-panel-tabs-content").hide();
			if (href == "#tempo-theme-public") {
				cleanRightConteiner();
				$("#tempo-publish-banner-tooltip").show()
				$("#tempo-banner-tooltip").hide();
				// 加号新增按钮置灰
				$(".tempo-strap-panel-title").find(".tempo-create-workspace").css("background-color",'rgb(228, 228, 228)').addClass("ui-state-disabled");
				if($pubThemeTree.data("tempo-gtree")){
					var item =$pubThemeTree.gtree("getSelected");
					if(item!=null&&item.fileType=='FILE'&&id==undefined){
						$pubThemeTree.gtree("clickItem",item.id);
					}
				}
				if (!$pubThemeTree.hasClass("tempo-gtree")&&id==undefined) {
					initPubTree({
						id : "-1",
						searchWord: searchWord,
						workSpaceId:workSpaceId,
						sort:themeTreeSort
					});
				}
			} else if(href == "#tempo-theme-private"){
				cleanRightConteiner();
				$(".tempo-strap-panel-title").find(".tempo-create-workspace").css("background-color",'#5185e4').removeClass("ui-state-disabled");
				$("#tempo-publish-banner-tooltip").hide()
				$("#tempo-banner-tooltip").show();
				 if ($themeTree.data("tempo-gtree")){
					 var item =$themeTree.gtree("getSelected");
						if(item!=null&&item.fileType=='FILE'){
							$themeTree.gtree("clickItem",item.id);
						}					
				 }
				
				if (!$themeTree.hasClass("tempo-gtree")) {
					var searchWord = "";
					if (analyse) {
						searchWord = analyse.name;
					}
					initExplorer({
						id : "-1",
						searchWord: searchWord,
						workSpaceId:workSpaceId,
						sort:themeTreeSort
					});
				}
			}
		});
// // 如果不是设计用户，禁用个人文件夹
// if (!isSJRY) {
// $themeTabs.children("li:last-child").addClass("ui-state-disabled");
// }
	}
	var cleanRightConteiner=function(){
			$rightappView.show();
			$rightdesignView.show();
			$rightappView.empty();
	}
	var initSearchbar = function(){
		// 左侧搜索框

		$searchBar.searchbar({
			width: 170,
			isEnter: true,
			placeholder:TempoUtils.locale("bidesign.tree_search_tip"),
			onSearch: function(text){
				initExplorer({
					id : "-1",
					searchWord:text,
					workSpaceId:workSpaceId,
					sort:themeTreeSort
				});
			}
		});
		if (analyse) {
			$searchBar.searchbar("setValue", analyse.name);
		}
		// 公共应用搜索框
		$pubSearchBar.searchbar({
			width: 170,
			isEnter: true,
			placeholder:TempoUtils.locale("bidesign.tree_pub_search_tip"),
			onSearch: function(text){
				initPubTree({
					id : "-1",
					searchWord: text,
					workSpaceId:workSpaceId,
					sort:themeTreeSort
				});
			}
		});
	}

	this.importCallback = function(data,isCover){
		if(theme.importFolder && data){
			$themeTree.gtree("removeItem", data.id);
			if (theme.isPub) {
				$themeTree.gtree("addItem", data, theme.importFolder.id);
			} else {
				var parentId = theme.importFolder.id;
				if(parentId==null&&$('.theme-container').attr("workspacetype")=='self'){
					parentId='-1';
				}
				data.fileType = "FILE";
				data.parentId = parentId;
				data.belong='1';
				$themeTree.gtree("addItem", data, parentId);
			}
			theme.isPub = null;
			theme.importFolder = null;
		}
	}

	var renameThemeUtils = {
			generateRenameThemeHtml:function(){
				var divHtml = "<table><tr><td><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bi.base_name")+"</label></td><td><input class='tempo-strap-dialog-info-input' type='text' id='themeName'><td></tr>";
				divHtml += "<tr><td><label class='tempo-strap-dialog-info-label'>"+TempoUtils.locale("bidesign.desc")+"</label></td><td><textarea class='tempo-strap-dialog-info-input' placeholder='"+TempoUtils.locale("bidesign.max_200_char")+"' style='height:40px;resize:none;width:263px' id='themeDescription'></textarea></td></tr></table>";
				return divHtml;
		
			},
			
			specialCharValidNotBracket :function(text){
//				var regexValid = /^[^~!@#\s\$%\^&\*\+\[\]\|\}\{\\;':,\/<>\?`]+$/;
//				if(!regexValid.test(text)){
//					return false;
//				}
				return true;
			},
			getRenNameUrl:function(type){ 
				 if(type==="theme_private"){
					return	url=contextPath + '/api/bi/resource/analyse/update'
				};
				return contextPath + '/api/bi/resource/pub-analyse/update';
			},
			updateItemName:function(type,id,name){
				 if(type==="theme_private"){
					  $themeTree.gtree("updateItemName", id,name);
					}else{
				      $pubThemeTree.gtree("updateItemName", id,name);
					}
			},
			renderHtml:function(dialog,data){
				dialogValiDateBoxUtil(dialog,"#themeName","resource.name_valid_tip",data.name);

               dialog.find("#themeDescription").validatebox({
                 maxLength:200,
                 autofill:false,
                 tip:TempoUtils.locale("bidesign.valid_tip_1"),
                 value:data.description||""
                 });
			  },
			valid:function(dialog){
				if(!dialog.find("#themeName").validatebox("doValidate")){
					return false;
				}
             
               if (dialog.find("#themeDescription").focus().val().length > 200){
                 failTip(TempoUtils.locale("bidesign.max_200_char"));
                   return false;
                 }
				return true;
			},
			getValue:function(dialog){
				return {
					name:dialog.find("#themeName").val().trim(),
					description:dialog.find("#themeDescription").val()
				};
			}
	}
	
	var dialogValiDateBoxUtil=function(dialog,ele,tipText,value){
		dialog.find(ele).validatebox({
			//valids:[/^[^~!@#\$%\^&\*\+\[\]\|\}\{\\;':",\.\/<>\?`]+$/],
			tip:TempoUtils.locale(tipText),
			required:true,
			maxLength:60,
			autofill:false,
			value:value||""
		});
	}
	
	var addThemeToobarSelectClass = function(ele) {
		ele.removeClass("ui-button");
		ele.removeClass("tempo-button");
		ele.addClass("theme-strap-header-toolbar-select");
	}
	
}


$(function() {
	var biTheme = new BiTheme();
	biTheme.init();
	new TempoResourceImportController(biTheme.importCallback).init();
});